/**
 * Created by SharkLock on 2017/4/15.
 */
(function ($) {
    var lesoft = window.lesoft = window.lesoft || {};
    var util = function () { };
    /*请求基础类*/
    util.prototype.request = function (url, data, successHandler, errorHandler, opts) {
        json = data ? self.stringify(data) : undefined,
            reqOpts = {
                timeout: 600000,
                global: true
            };
        $.extend(reqOpts, opts);
        $.ajax({
            type: "POST",
            url: url,
            cache: false,
            global: reqOpts.global,
            timeout: reqOpts.timeout,
            processData: false,
            data: json,
            contentType: 'application/json',
            success: function (result) {
                try {
                    successHandler && successHandler(result);
                } catch (e) {
                    console.log(e);
                }
            },
            error: function (jqXHR, textStatus, error) {
                if (errorHandler) {
                    errorHandler(jqXHR, textStatus, error);
                } else {
                    console.log(error);
                }
            }
        });
    }
    $.extend(lesoft.util, { util: new util() });
})(jQuery)
